package cn.tedu.spring2205.week02.life;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        //对Bean进行操作。。。。，最后需要返回操作后的Bean
        System.err.println(beanName+"调用初始化器前执行操作。。。。。。");
        return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.err.println(beanName+"在初始化器调用之后执行操作。。。。。");
        return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
    }
}
